/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * frmLapHoaDon.java
 *
 * Created on Aug 27, 2012, 9:23:42 AM
 */
package gui;

import dao.SanPhamDAO;
import java.text.Format;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Vector;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import pojo.*;
import dao.*;
import org.hibernate.HibernateException;

/**
 *
 * @author dtth
 */
public class frmLapHoaDon extends javax.swing.JFrame {

    //Vùng khai báo biến
    //private static Cuahang pojoCuaHang = null;
    private static Cuahang pojoCuaHang = new Cuahang(1, "Cua hang 1", "Nguyen Hong Hai", "Quan 7", "016152486", null, null);
    private static Nhanvien pojoNhanVien = new Nhanvien(1,"Lâm Văn Sơn");
    //private static Nhanvien pojoNhanVien = null;
    private static Sanpham pojoSanPham = null;
    private static Donvitinh pojoDonViTinh = null;
    private static Khachhang pojoKhachHang = null;
    private DefaultTableModel TableModel;
    private static int iSoLuongSP = 1;
    private static Vector rowHeader = new Vector();
    private static String strNgayLapHoaDon = "";
    private static Double dTongThanhTien = 0.0;
    
    //Kết thúc Vùng khai báo biến
    
    //Vùng xây dựng các phương thức
    public void LoadThongTinCuaHang() {
        try {
            if(pojoCuaHang != null) {
                this.jlblTenDonViBanHang.setText(pojoCuaHang.getTencuahang());
                this.jlblDiaChiDonViBanHang.setText(pojoCuaHang.getDiachi());
                this.jlblTenChuCuaHang.setText(pojoCuaHang.getChucuahang());
                this.jlblSoDienThoaiCuaHang.setText(pojoCuaHang.getSdt());
            }
        } catch(Exception ex) {
            
        }
    }
    
    public void LoadNgayLapPhieu() {
        try {
            Format formater = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss.SSS");
            Date d = new Date();
            strNgayLapHoaDon = formater.format(d);
        } catch(Exception ex) {
            
        }
        
    }
    
    public void LoadThongTinSanPham() {
        try {
            //Load danh sách sản phẩm
            List<Sanpham> listSP = SanPhamDAO.layDanhSachSanPham();
            for (int i = 0; i < listSP.size(); i++) {
                Sanpham sp = listSP.get(i);
                jcbxDanhSachSanPham.addItem(sp);
            }
            
            //Load thông tin chi tiết
            
        } catch(Exception ex) {
            JOptionPane.showMessageDialog(this, "Loi: " + ex.toString(), "Thông báo", JOptionPane.ERROR_MESSAGE);
        }
    }

    public void LoadThongTinKhachHang() {
        try {
            List<Khachhang> listKH = KhachHangDAO.layDanhSachKhachHang();
            for (int i = 0; i < listKH.size(); i++) {
                Khachhang kh = listKH.get(i);
                jcbxDanhSachKhachHang.addItem(kh);
            }
        } catch(Exception ex) {
            JOptionPane.showMessageDialog(this, "Loi: " + ex.toString(), "Thông báo", JOptionPane.ERROR_MESSAGE);
        }
    }
    
    public void CreateHeaderTableSanPham() {
        try {
            TableModel = new DefaultTableModel(new Vector(),0);
            rowHeader.addElement("STT");    
            rowHeader.addElement("Mã SP");
            rowHeader.addElement("Tên SP");    
            rowHeader.addElement("Số Lượng");
            rowHeader.addElement("Đơn Giá");    
            rowHeader.addElement("ĐVT");    
            rowHeader.addElement("Thành Tiền");
            
            TableModel = new DefaultTableModel(rowHeader, 0);
            jTableListSanPham.setModel(TableModel);
        } catch(Exception ex) {
            
        }
    }
    
    public void CreateTableSanPham(String prMaSP, String prTenSP, String prSoLuong, String prDVT, String prDonGia, String prThanhTien) {
        try {
            for (int i = TableModel.getRowCount() - 1; i >= 0; i-- ){
                String strMaSP = jTableListSanPham.getModel().getValueAt(i, 1).toString();
                Double dSLSPTable = Double.valueOf(jTableListSanPham.getModel().getValueAt(i, 3).toString());
                Double dSLSPMoi = Double.valueOf(prSoLuong);
                Double dSLSP = dSLSPTable + dSLSPMoi;
                if(strMaSP.equals(prMaSP)) {
                    jTableListSanPham.getModel().setValueAt(dSLSP, i, 3);
                    return;
                }
            }

            Vector row = new Vector();
            row.addElement(String.valueOf(iSoLuongSP));
            row.addElement(prMaSP);
            row.addElement(prTenSP);
            row.addElement(prSoLuong);
            row.addElement(prDonGia);
            row.addElement(prDVT);
            row.addElement(prThanhTien);
            row.addElement(prMaSP);
            TableModel.addRow(row);
            iSoLuongSP++;
            jTableListSanPham.setModel(TableModel);
        } catch(Exception ex) {
            
        }
    }
    
    public void LoadData() {
        LoadNgayLapPhieu();
        LoadThongTinCuaHang();
        LoadThongTinSanPham();
        CreateHeaderTableSanPham();
        LoadThongTinKhachHang();
        this.jlblTenNhanVienLapPhieu.setText(pojoNhanVien.getTennhanvien());
        this.jlblNgayLapPhieu.setText(strNgayLapHoaDon);
    }
    //Kết thức Vùng xây dựng các phương thức
    
    /** Creates new form frmLapHoaDon */
    public frmLapHoaDon() {
        initComponents();
        LoadData();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jlblTenNhanVienLapPhieu = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jtxtDiaChiKH = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jtxtSDTKH = new javax.swing.JTextField();
        jtxtEmailKH = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        jcbxDanhSachKhachHang = new javax.swing.JComboBox();
        jLabel20 = new javax.swing.JLabel();
        jbtnThem2 = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTableListSanPham = new javax.swing.JTable();
        jbtnDong = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jlblTenDonViBanHang = new javax.swing.JLabel();
        jlblTenChuCuaHang = new javax.swing.JLabel();
        jlblSoDienThoaiCuaHang = new javax.swing.JLabel();
        jlblDiaChiDonViBanHang = new javax.swing.JLabel();
        jlblNgayLapPhieu = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jcbxDanhSachSanPham = new javax.swing.JComboBox();
        jtxtSoLuongSP = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jbtnHuy1 = new javax.swing.JButton();
        jbtnThem1 = new javax.swing.JButton();
        jlblDonGiaSP = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jlblDonViTinh = new javax.swing.JLabel();
        jbtnDong1 = new javax.swing.JButton();
        jbtnThanhToanHoaDon = new javax.swing.JButton();
        jLabel24 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        jLabel27 = new javax.swing.JLabel();
        jLabel28 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("LẬP HÓA ĐƠN BÁN HÀNG");

        jlblTenNhanVienLapPhieu.setFont(new java.awt.Font("Tahoma", 0, 12));
        jlblTenNhanVienLapPhieu.setText("[Unknow]");

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel5.setText("Nhân viên lập phiếu:");

        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel1.setToolTipText("");
        jPanel1.setFont(new java.awt.Font("Tahoma", 0, 12));
        jPanel1.setName(""); // NOI18N

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel2.setText("Tên KH");
        jLabel2.setToolTipText("");

        jtxtDiaChiKH.setEditable(false);
        jtxtDiaChiKH.setFont(new java.awt.Font("Tahoma", 0, 12));

        jLabel7.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel7.setText("Địa chỉ");
        jLabel7.setToolTipText("");

        jtxtSDTKH.setEditable(false);
        jtxtSDTKH.setFont(new java.awt.Font("Tahoma", 0, 12));

        jtxtEmailKH.setEditable(false);
        jtxtEmailKH.setFont(new java.awt.Font("Tahoma", 0, 12));

        jLabel19.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel19.setText("Email");
        jLabel19.setToolTipText("");

        jcbxDanhSachKhachHang.setFont(new java.awt.Font("Tahoma", 0, 12));
        jcbxDanhSachKhachHang.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "[Chọn khách hàng]" }));
        jcbxDanhSachKhachHang.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcbxDanhSachKhachHangActionPerformed(evt);
            }
        });

        jLabel20.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel20.setText("SĐT");
        jLabel20.setToolTipText("");

        jbtnThem2.setText("Thêm Mới Khách Hàng");
        jbtnThem2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbtnThem2MouseClicked(evt);
            }
        });
        jbtnThem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnThem2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel7)
                    .addComponent(jLabel2))
                .addGap(50, 50, 50)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jtxtDiaChiKH)
                    .addComponent(jcbxDanhSachKhachHang, 0, 337, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel20)
                    .addComponent(jLabel19))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jtxtSDTKH)
                    .addComponent(jtxtEmailKH, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE))
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(538, Short.MAX_VALUE)
                .addComponent(jbtnThem2, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jtxtSDTKH, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel20))
                        .addGap(6, 6, 6)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jtxtEmailKH, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel19)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(jcbxDanhSachKhachHang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel7)
                            .addComponent(jtxtDiaChiKH, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbtnThem2, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTableListSanPham.setFont(new java.awt.Font("Tahoma", 0, 12));
        jTableListSanPham.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        jTableListSanPham.setFillsViewportHeight(true);
        jScrollPane1.setViewportView(jTableListSanPham);

        jbtnDong.setText("Đóng");
        jbtnDong.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbtnDongMouseClicked(evt);
            }
        });
        jbtnDong.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnDongActionPerformed(evt);
            }
        });

        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel2.setToolTipText("");
        jPanel2.setFont(new java.awt.Font("Tahoma", 0, 12));
        jPanel2.setName(""); // NOI18N

        jLabel8.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel8.setText("Đơn vị bán hàng:");
        jLabel8.setToolTipText("");

        jLabel10.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel10.setText("Số điện thoại:");
        jLabel10.setToolTipText("");

        jLabel11.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel11.setText("Chủ cửa hàng:");
        jLabel11.setToolTipText("");

        jLabel12.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel12.setText("Địa chỉ:");
        jLabel12.setToolTipText("");

        jlblTenDonViBanHang.setFont(new java.awt.Font("Tahoma", 0, 12));
        jlblTenDonViBanHang.setText("[Unkown]");
        jlblTenDonViBanHang.setToolTipText("");

        jlblTenChuCuaHang.setFont(new java.awt.Font("Tahoma", 0, 12));
        jlblTenChuCuaHang.setText("[Unknow]");
        jlblTenChuCuaHang.setToolTipText("");

        jlblSoDienThoaiCuaHang.setFont(new java.awt.Font("Tahoma", 0, 12));
        jlblSoDienThoaiCuaHang.setText("[Unknow]");
        jlblSoDienThoaiCuaHang.setToolTipText("");

        jlblDiaChiDonViBanHang.setFont(new java.awt.Font("Tahoma", 0, 12));
        jlblDiaChiDonViBanHang.setText("[Unkown]");
        jlblDiaChiDonViBanHang.setToolTipText("");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel8)
                    .addComponent(jLabel12))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jlblDiaChiDonViBanHang)
                    .addComponent(jlblTenDonViBanHang))
                .addGap(175, 175, 175)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel11)
                    .addComponent(jLabel10))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jlblSoDienThoaiCuaHang)
                    .addComponent(jlblTenChuCuaHang))
                .addContainerGap(214, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel10))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jlblTenChuCuaHang)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jlblSoDienThoaiCuaHang))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel8)
                            .addComponent(jlblTenDonViBanHang))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel12)
                            .addComponent(jlblDiaChiDonViBanHang))))
                .addContainerGap(11, Short.MAX_VALUE))
        );

        jlblNgayLapPhieu.setFont(new java.awt.Font("Tahoma", 0, 12));
        jlblNgayLapPhieu.setText("[Unknow]");

        jLabel13.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel13.setText("Ngày giờ lập phiếu:");

        jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel3.setToolTipText("");
        jPanel3.setFont(new java.awt.Font("Tahoma", 0, 12));
        jPanel3.setName(""); // NOI18N

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel4.setText("Tên SP");
        jLabel4.setToolTipText("");

        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel6.setText("Đơn giá:");
        jLabel6.setToolTipText("");

        jcbxDanhSachSanPham.setFont(new java.awt.Font("Tahoma", 0, 12));
        jcbxDanhSachSanPham.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "[Chọn danh mục SP]" }));
        jcbxDanhSachSanPham.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jcbxDanhSachSanPhamMouseClicked(evt);
            }
        });
        jcbxDanhSachSanPham.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jcbxDanhSachSanPhamItemStateChanged(evt);
            }
        });
        jcbxDanhSachSanPham.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcbxDanhSachSanPhamActionPerformed(evt);
            }
        });

        jtxtSoLuongSP.setFont(new java.awt.Font("Tahoma", 0, 12));
        jtxtSoLuongSP.setText("1");

        jLabel9.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel9.setText("Số lượng:");
        jLabel9.setToolTipText("");

        jbtnHuy1.setText("Hủy");
        jbtnHuy1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbtnHuy1MouseClicked(evt);
            }
        });
        jbtnHuy1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnHuy1ActionPerformed(evt);
            }
        });

        jbtnThem1.setText("Chọn");
        jbtnThem1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbtnThem1MouseClicked(evt);
            }
        });
        jbtnThem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnThem1ActionPerformed(evt);
            }
        });

        jlblDonGiaSP.setFont(new java.awt.Font("Tahoma", 0, 12));
        jlblDonGiaSP.setText("[Unkown]");
        jlblDonGiaSP.setToolTipText("");

        jLabel14.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel14.setText("Đơn vị tính:");
        jLabel14.setToolTipText("");

        jlblDonViTinh.setFont(new java.awt.Font("Tahoma", 0, 12));
        jlblDonViTinh.setText("[Unkown]");
        jlblDonViTinh.setToolTipText("");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addComponent(jLabel9)
                            .addComponent(jLabel6))
                        .addGap(38, 38, 38)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jlblDonGiaSP, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jtxtSoLuongSP, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(26, 26, 26)
                                .addComponent(jLabel14)
                                .addGap(18, 18, 18)
                                .addComponent(jlblDonViTinh, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jcbxDanhSachSanPham, 0, 529, Short.MAX_VALUE)
                                .addGap(62, 62, 62))))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                        .addComponent(jbtnThem1, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbtnHuy1, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jcbxDanhSachSanPham, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jtxtSoLuongSP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jlblDonViTinh)
                    .addComponent(jLabel14))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jlblDonGiaSP))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbtnHuy1, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbtnThem1, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jbtnDong1.setText("In Hóa Đơn");
        jbtnDong1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbtnDong1MouseClicked(evt);
            }
        });
        jbtnDong1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnDong1ActionPerformed(evt);
            }
        });

        jbtnThanhToanHoaDon.setText("Thanh Toán");
        jbtnThanhToanHoaDon.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbtnThanhToanHoaDonMouseClicked(evt);
            }
        });
        jbtnThanhToanHoaDon.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnThanhToanHoaDonActionPerformed(evt);
            }
        });

        jLabel24.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel24.setText("[Unkown]");
        jLabel24.setToolTipText("");

        jLabel23.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel23.setText("Tổng tiền:");
        jLabel23.setToolTipText("");

        jLabel25.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel25.setText("[Unkown]");
        jLabel25.setToolTipText("");

        jLabel26.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel26.setText("Tiền thuế");
        jLabel26.setToolTipText("");

        jLabel27.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel27.setText("[Unkown]");
        jLabel27.setToolTipText("");

        jLabel28.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel28.setText("Tổng thành tiền:");
        jLabel28.setToolTipText("");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 706, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jlblTenNhanVienLapPhieu)
                        .addGap(165, 165, 165)
                        .addComponent(jLabel13)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jlblNgayLapPhieu))
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel28)
                            .addComponent(jLabel23)
                            .addComponent(jLabel26))
                        .addGap(10, 10, 10)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel25, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel24, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(95, 95, 95)
                                .addComponent(jbtnThanhToanHoaDon, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jbtnDong1, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jbtnDong, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel27, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 706, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jlblTenNhanVienLapPhieu)
                    .addComponent(jLabel13)
                    .addComponent(jlblNgayLapPhieu))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel23)
                            .addComponent(jLabel24))
                        .addGap(1, 1, 1)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel26)
                            .addComponent(jLabel25))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel28)
                            .addComponent(jLabel27)))
                    .addComponent(jbtnDong, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbtnDong1, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbtnThanhToanHoaDon, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void jbtnDongMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jbtnDongMouseClicked
// TODO add your handling code here:
    this.setVisible(false);
}//GEN-LAST:event_jbtnDongMouseClicked

private void jcbxDanhSachSanPhamMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jcbxDanhSachSanPhamMouseClicked
// TODO add your handling code here:
}//GEN-LAST:event_jcbxDanhSachSanPhamMouseClicked

private void jcbxDanhSachSanPhamItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jcbxDanhSachSanPhamItemStateChanged
// TODO add your handling code here:
//    Sanpham sp = (Sanpham) this.jcbxDanhSachSanPham.getSelectedItem();
//    JOptionPane.showMessageDialog(this, "Bạn vừa chọn SP: " + sp.toString(), "Thông báo", JOptionPane.INFORMATION_MESSAGE);
}//GEN-LAST:event_jcbxDanhSachSanPhamItemStateChanged

private void jcbxDanhSachSanPhamActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbxDanhSachSanPhamActionPerformed
// TODO add your handling code here:
    if(this.jcbxDanhSachSanPham.getSelectedIndex() != 0) {
        pojoSanPham = (Sanpham) this.jcbxDanhSachSanPham.getSelectedItem();
        NumberFormat formatter = NumberFormat.getNumberInstance();
        String strDonGia = formatter.format(pojoSanPham.getDongia()) + " VNĐ";
        this.jlblDonGiaSP.setText(strDonGia);

        pojoDonViTinh = pojoSanPham.getDonvitinh();
        this.jlblDonViTinh.setText(pojoDonViTinh.getTendonvitinh());
    }
}//GEN-LAST:event_jcbxDanhSachSanPhamActionPerformed

private void jbtnHuy1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jbtnHuy1MouseClicked
// TODO add your handling code here:
    
}//GEN-LAST:event_jbtnHuy1MouseClicked

private void jbtnThem1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jbtnThem1MouseClicked
// TODO add your handling code here:
    
}//GEN-LAST:event_jbtnThem1MouseClicked

private void jbtnThem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnThem1ActionPerformed
// TODO add your handling code here:
    //JOptionPane.showMessageDialog(this, "Bạn vừa chọn SP: " + pojoSanPham.toString(), "Thông báo", JOptionPane.INFORMATION_MESSAGE);
    
    if(this.jcbxDanhSachKhachHang.getSelectedIndex() == 0) {
        //JOptionPane.showMessageDialog(this, jcbxDanhSachKhachHang.getSelectedIndex(), "Thông báo", JOptionPane.INFORMATION_MESSAGE);
        JOptionPane.showMessageDialog(this, "Vui lòng chọn Khách hàng, nếu Khách hàng không tồn tại thì vui lòng tạo mới khách hàng.", "Thông báo", JOptionPane.INFORMATION_MESSAGE);
    }
    if(this.jcbxDanhSachSanPham.getSelectedIndex() != 0) {
        int iMaSP = pojoSanPham.getMasanpham();
        String strMaSP = String.valueOf(iMaSP);
        String strTenhang = pojoSanPham.getTensanpham();
        Double dSoLuong = 1.0;
        try {
            dSoLuong = Double.parseDouble(this.jtxtSoLuongSP.getText());
        } catch(NumberFormatException ex) {
            JOptionPane.showMessageDialog(this, "Số lượng phải là số, vui lòng nhập lại.", "Thông báo", JOptionPane.INFORMATION_MESSAGE);
            this.jtxtSoLuongSP.setText("");
            this.jtxtSoLuongSP.requestFocusInWindow();
            return;
        }
        String strSoLuong = String.valueOf(dSoLuong);
        String dvt = pojoDonViTinh.getTendonvitinh();
        String strDonGia = String.valueOf(pojoSanPham.getDongia());
        Double dThanhTien = dSoLuong * pojoSanPham.getDongia();
        String strThanhTien = String.valueOf(dThanhTien);

        CreateTableSanPham(strMaSP, strTenhang, strSoLuong, dvt, strDonGia, strThanhTien);
    }
}//GEN-LAST:event_jbtnThem1ActionPerformed

private void jbtnDong1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jbtnDong1MouseClicked
// TODO add your handling code here:
    
}//GEN-LAST:event_jbtnDong1MouseClicked

private void jbtnThanhToanHoaDonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jbtnThanhToanHoaDonMouseClicked
// TODO add your handling code here:
    
}//GEN-LAST:event_jbtnThanhToanHoaDonMouseClicked

private void jbtnDongActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnDongActionPerformed
// TODO add your handling code here:
    this.setVisible(false);
}//GEN-LAST:event_jbtnDongActionPerformed

private void jbtnHuy1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnHuy1ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jbtnHuy1ActionPerformed

private void jbtnThem2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jbtnThem2MouseClicked
// TODO add your handling code here:
}//GEN-LAST:event_jbtnThem2MouseClicked

private void jbtnThem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnThem2ActionPerformed
// TODO add your handling code here:
    JOptionPane.showMessageDialog(this, "Chức năng này do Nguyễn Phước Duy thực hiện.", "Thông báo", JOptionPane.INFORMATION_MESSAGE);
}//GEN-LAST:event_jbtnThem2ActionPerformed

private void jcbxDanhSachKhachHangActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbxDanhSachKhachHangActionPerformed
// TODO add your handling code here:
    if(this.jcbxDanhSachKhachHang.getSelectedIndex() != 0) {
        pojoKhachHang = (Khachhang) this.jcbxDanhSachKhachHang.getSelectedItem();
        this.jtxtDiaChiKH.setText(pojoKhachHang.getDiachi());
        this.jtxtSDTKH.setText(pojoKhachHang.getSdt());
        this.jtxtEmailKH.setText(pojoKhachHang.getEmail());
    }
}//GEN-LAST:event_jcbxDanhSachKhachHangActionPerformed

private void jbtnDong1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnDong1ActionPerformed
// TODO add your handling code here:
    JOptionPane.showMessageDialog(this, "Chức năng này được thực hiện trong bài tập tiếp theo.", "Thông báo", JOptionPane.INFORMATION_MESSAGE);
}//GEN-LAST:event_jbtnDong1ActionPerformed

private void jbtnThanhToanHoaDonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnThanhToanHoaDonActionPerformed
// TODO add your handling code here:
    try {
        LoadNgayLapPhieu();
        // Lưu thông tin hóa đơn vào bảng Hóa đơn  
        String strTenHoaDon = "HD " + strNgayLapHoaDon;
        
        // Tính tổng thành tiền
        dTongThanhTien = 0.0;
        for (int i = TableModel.getRowCount() - 1; i >= 0; i-- ){
                Double dSLSP = Double.valueOf(jTableListSanPham.getModel().getValueAt(i, 3).toString());
                Double dDonGia = Double.valueOf(jTableListSanPham.getModel().getValueAt(i, 4).toString());
                dTongThanhTien += dSLSP * dDonGia;
        }
        Hoadon hd = new Hoadon(pojoKhachHang, pojoNhanVien, strTenHoaDon, dTongThanhTien, new Date(), true, null);
        boolean isKQ = HoaDonDAO.themHoaDon(hd);

        if (isKQ) {
            // Lưu thông tin hóa đơn và sản phẩm vào bảng Chi tiết Hóa đơ
            boolean isKiemTra = true;
            for (int i = TableModel.getRowCount() - 1; i >= 0; i-- ){
                String strMaSP = jTableListSanPham.getModel().getValueAt(i, 1).toString();
                Double dSLSP = Double.valueOf(jTableListSanPham.getModel().getValueAt(i, 3).toString());
                Double dDonGia = Double.valueOf(jTableListSanPham.getModel().getValueAt(i, 4).toString());
                Chitiethoadon cthd = new Chitiethoadon(pojoSanPham, hd, iSoLuongSP, dDonGia);
                boolean isKQ_CTHD = ChiTietHoaDonDAO.themChiTietHoaDon(cthd);
                if (!isKQ_CTHD) {
                    isKiemTra = false;
                }
            }
            if (isKiemTra) {
                JOptionPane.showMessageDialog(this, "Lưu hóa đơn thành công.", "Thông báo", JOptionPane.INFORMATION_MESSAGE);
            }
        }
       //JOptionPane.showMessageDialog(this, isKQ, "Thông báo", JOptionPane.INFORMATION_MESSAGE);
//        boolean isKQ = HoaDonDAO.themHoaDon(hd);
//        if (isKQ) {
//            JOptionPane.showMessageDialog(this, "Thành công.", "Thông báo", JOptionPane.INFORMATION_MESSAGE);
//        } else {
//            JOptionPane.showMessageDialog(this, "Quá trình thanh toán có lỗi.", "Thông báo", JOptionPane.INFORMATION_MESSAGE);
//        }
    } catch (HibernateException ex) {
        //JOptionPane.showMessageDialog(this, ex.toString(), "Thông báo", JOptionPane.INFORMATION_MESSAGE);
        System.out.println(ex.toString());
    }catch (Exception ex) {
        System.out.println(ex.toString());
    } 
}//GEN-LAST:event_jbtnThanhToanHoaDonActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(frmLapHoaDon.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(frmLapHoaDon.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(frmLapHoaDon.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(frmLapHoaDon.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
        
        /* Create and display the form */
       
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new frmLapHoaDon().setVisible(true);
            }
        });
    }
    public static void setInformation(Nhanvien clsNhanVien, Cuahang clsCuaHang) {
        pojoCuaHang = clsCuaHang;
        pojoNhanVien = clsNhanVien;
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTableListSanPham;
    private javax.swing.JButton jbtnDong;
    private javax.swing.JButton jbtnDong1;
    private javax.swing.JButton jbtnHuy1;
    private javax.swing.JButton jbtnThanhToanHoaDon;
    private javax.swing.JButton jbtnThem1;
    private javax.swing.JButton jbtnThem2;
    private javax.swing.JComboBox jcbxDanhSachKhachHang;
    private javax.swing.JComboBox jcbxDanhSachSanPham;
    private javax.swing.JLabel jlblDiaChiDonViBanHang;
    private javax.swing.JLabel jlblDonGiaSP;
    private javax.swing.JLabel jlblDonViTinh;
    private javax.swing.JLabel jlblNgayLapPhieu;
    private javax.swing.JLabel jlblSoDienThoaiCuaHang;
    private javax.swing.JLabel jlblTenChuCuaHang;
    private javax.swing.JLabel jlblTenDonViBanHang;
    private javax.swing.JLabel jlblTenNhanVienLapPhieu;
    private javax.swing.JTextField jtxtDiaChiKH;
    private javax.swing.JTextField jtxtEmailKH;
    private javax.swing.JTextField jtxtSDTKH;
    private javax.swing.JTextField jtxtSoLuongSP;
    // End of variables declaration//GEN-END:variables
}
